aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/[username]/request/+page.server.js
blob: f32c118caf452c77d516c6c65c769bc4d9f25324 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { redirect } from '@sveltejs/kit';
import { auth, post } from '$lib/utils';

export let load = ({ locals }) => {
	if (!locals.user) throw redirect(307, '/login');
};

export const actions = {
	default: async ({ cookies, request, url }) => {
		let form = Object.fromEntries(await request.formData());
		await post('/requests', form, auth(cookies));
		throw redirect(307, url.href + '/sent');
	}
};